$(".list").animate({
    left: (innerWidth - $(".list").width()) / 2,
    top: (innerHeight - $(".list").height()) / 2
}, 0);
async function login(name) {
    var user = $("#user").val();
    let pass = $("#pass").val();
    let res = await pAjax({
        url: `/api/project/${name}.php`,
        data: {
            username:user,
            password:pass

        }
        
    })
    console.log(JSON.parse(res));
    res = JSON.parse(res);
    if (res.code == 1 && name == 'adminlogin') {
        setCookie("login", user);
        location.href = "./html/adminui.html";
    } else if (res.code == 1 && name=='supervisoruser') {
        console.log(2);
    } else if (res.code == 1 && name == 'studetlogin') {
        setCookie("login", user, 120);
        location.href = "./html/student.html";
    } else {
        alert("用户名或密码错误，请重新输入");
        $("#user").val('');
        $("#pass").val('');
    }
}
$(".btn").on("click", function (e) {
    e = e || window.Event;
    e.preventDefault();
    let rex = $("input[name='idx']:checked").val();
    switch (rex) {
        case '1':login('adminlogin');break
        case '2': login('supervisoruser'); break
        case '3': login('studetlogin'); break
        default :alert("请勾选登录类型")
    }

   
})
    
    
